/*
{
"状态":1,
"名称":"获取-供应商信息",
"作者":"陈泽椿",
"创建时间":"2018-06-30",
"功能":"获取-供应商信息",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/
declare @sql nvarchar(max)
declare @supplier_name varchar(100)
declare @where varchar(max)
declare @pagesize INT
declare @currentpage INT    
 
set @supplier_name = '{supplier_name}'
set @pagesize = {pagesize}
set @currentpage = {currentpage}
set @where = ''

if(@supplier_name <>'')
begin
	set @where += ' and (supplier_name like ''%' + @supplier_name + '%''  or supplier_no like ''%' + @supplier_name + '%''  or simple_code like ''%' + @supplier_name + '%'')'
end
if @pagesize<0
begin 
 set @sql = '
	select 0 id, supplier_id, supplier_no,supplier_name,short_name,fax, phone,contacter,sup_address,landline,
	convert(varchar(20),create_time,120)create_time,create_user,
	convert(varchar(20),update_time,120)update_time,update_user from b_supplier where 1 = 1 {where}
	'
end
else
begin  
set @sql = '
	select * from 
	(
	select ROW_NUMBER() OVER(ORDER BY supplier_id) AS id, supplier_id, supplier_no,supplier_name,short_name,fax, phone,contacter,sup_address,landline,
	convert(varchar(20),create_time,120)create_time,create_user,
	convert(varchar(20),update_time,120)update_time,update_user from b_supplier where 1 = 1 {where}
	) A 
	WHERE id BETWEEN @pagesize*(@currentpage-1)+1 AND @pagesize*@currentpage
	'
end
set @sql = replace(@sql,'{where}',@where)
EXEC sp_executesql @sql,N'@pagesize int,@currentpage int',@pagesize,@currentpage
 